﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Configuration;

namespace DynamicImage
{
  public class DynamicImageProcessorConfig : ConfigurationSection
  {
    [ConfigurationProperty("EnableImageNotFound", DefaultValue = "false", IsRequired = false)]
    public Boolean EnableImageNotFound
    {
      get
      {
        return (Boolean)this["EnableImageNotFound"];
      }
      set
      {
        this["EnableImageNotFound"] = value;
      }
    }

    [ConfigurationProperty("DefaultMimeType", DefaultValue = "image/jpeg", IsRequired = false)]
    public string DefaultMimeType
    {
      get
      {
        return (string)this["DefaultMimeType"];
      }
      set
      {
        this["DefaultMimeType"] = value;
      }
    }

    [ConfigurationProperty("ImageNotFound")]
    public imageNotFound ImageNotFound 
    {
      get
      { 
        return (imageNotFound)this["ImageNotFound"];
      }
      set
      { 
        this["ImageNotFound"] = value;  
      }
    }

    [ConfigurationProperty("Cache")]
    public cache Cache
    {
      get
      {
        return (cache)this["Cache"];
      }
      set
      {
        this["Cache"] = value;
      }
    }

    public class imageNotFound : ConfigurationElement
    {
      [ConfigurationProperty("FileName", DefaultValue = "", IsRequired = false)]
      public string FileName
      {
        get
        {
          return (string)this["FileName"];
        }
        set
        {
          this["FileName"] = value;
        }
      }

    }

    public class cache : ConfigurationElement
    {
      [ConfigurationProperty("CacheDirectory", DefaultValue = "", IsRequired=false)]
      public string CacheDirectory
      {
        get
        {
          return (string)this["CacheDirectory"];
        }
        set
        {
          this["CacheDirectory"] = value;
        }
      }

      [ConfigurationProperty("Enabled", DefaultValue= "false", IsRequired=false)]
      public Boolean Enabled
      {
        get
        {
          return (Boolean)this["Enabled"];
        }
        set
        {
          this["Enabled"] = value;
        }
      }

    }
  }
}
